home *** CD-ROM | disk | FTP | other *** search
- DMAmon by Simon N Goodwin
-
- DMAmon indicates in a Workbench window when Amiga disk drives
- and sound channels are in use. Source code in HiSoft BASIC is
- included.
-
- This program is an expanded version of a utility written by
- Simon N Goodwin for the current Amiga Format magazine tutorial
- series 'Banging The Metal'. This special version for Aminet is
- published under the author's agreement with Future Publishing,
- which allows non-exclusive distribution of material written for
- the magazine, six months after publication. It is hoped that
- other examples and tutorials wil lbe made more widely available
- this way. You can already read an extended version of the Amiga
- Format Emulation series on the web, thanks to Simon Goodwin and
- Thomas Amsrud, who translated the original to HTML. To read
- this, go to:
-
- http://www.emulnews.com/aer/articles/af/
-
- The example program
-
- DMAmon uses HiSoft BASIC to monitor disk and audio memory
- access. It works by checking the DMACONR and DSKBYTR registers
- at regular intervals.The only explicit system call is to Delay,
- in the DOS library, linked by the first couple of lines. This
- prevents the program hogging the CPU, updating faster than the
- eye can see, by periodically surrendering time to other tasks.
-
- The value after Delay, near the end, counts display fields
- before the loop repeats. Press Control C to stop the task. On my
- PAL A4000 Delay &20 permits updates two or three times per
- second, draining less than 1.5 per cent of the CPU time. Delay
- &10 updates twice as fast, six times per second on NTSC
- displays, and so on. Alternatively you might give the program a
- negative priority, so it defers to foreground tasks.
-
- Scattered &s indicate HiSoft BASIC long word values, versus %
- for 16 bit integers. &H preceeds hex values (like $ in assembler
- or 0x in C) such as the custom register base, &hDFF000, and &B
- denotes binary.
-
- Disk DMA
-
- The floppy disk DMA channel can read or write data to up to four
- drives. The second and third most significant bits in DSKBYTR
- show when this is happening. The second (bit 14, masked out with
- binary in the listing) is set while disk DMA is is progress. The
- third (bit 13) is set during floppy writes.
-
- This helps reveal why your drives are grinding away. Some
- programs leave the drive motors running when there's no DMA, so
- disks can safely be removed. Beware of removing a disk even when
- apparently just reading; the system may switch to writing before
- your finger reaches the eject button. You'll soon learn when
- this is likely, with DMAmon as your guide.
-
- Sound DMA
-
- It's similarly useful to monitor active sound channels. Sound
- channels are a scarce resource and should be shared. Some
- applications require channels, and a few nasty ones hog them,
- even when not in use. DMAmon shows the status of each of the
- four channels dynamically, with 0 for a free channel and 1 if
- the channel is in use.
-
- You could recode this to use graphics or left/right grouping
- rather than hardware chanel order. I've done it the obvious way
- for BASIC, extracting four adjacent bits with AND then
- converting to binary with BIN$. The prefix "000" and RIGHT$(,4)
- make leading zeros explicit.
-
- Typically, Amiga registers combine several functions, assigning
- distinct control to each bit. Each one or zero bit indicates a
- distinct state in the underlying hardware. The table lists the
- significance of bits in DMACONR and DSKBYTR.
-
- DMACONR is a read-only version of DMACON. Like other crucial
- controls, the 'top' (most significant) bit indicates setting or
- clearing of other bits - so a single write with one bit set
- CLEARs just that bit! If the top bit and others are set, those
- are added to the ones already set. This brilliance saves
- reading, masking and writing values back, and eases Copper
- programming.
-
- These are readily accessible, but not the only DMA control bits.
- BPLCON ($DFF100) determines the number of bitplanes in use.
- There's no BPLCONR so you must record changes. DMAmon does not
- monitor bitplane DMA as it's static for a given display mode,
- and you won't see anything if it's turned off! Sprite DMA could
- be monitored but most programs disable sprites by changing to a
- small transparent pattern or parking them in the border, rather
- than stopping their DMA.
-
- The Copper is constantly active, but usually only gains priority
- over the CPU for a few microseconds at a time. It would be
- interesting to monitor Blitter activity, but difficult in Amiga
- OS windows; the system uses blits to update them, so you can't
- report the Blitter's status unless it is idle!
-
- Simon N Goodwin, Oldbury, March 1999, Aminet Update October 1999
-
- Table: Sample DMA register bit assignments
-
- Bit DMACON DSKBYTR
-
- 15 Set/Clear Data Valid
- 14 Blitter Busy DMA active
- 13 Blitter Zero Disk writing
- 12 Unassigned Sync match
- 11 Unassigned Unassigned
- 10 Blitter Nasty Unassigned
- 9 Master DMA Unassigned
- 8 Bitplane DMA Unassigned
- 7 Copper DMA Data bit 7
- 6 Blitter DMA Data bit 6
- 5 Sprite DMA Data bit 5
- 4 Floppy DMA Data bit 4
- 3 Right audio 2 Data bit 3
- 2 Left audio 2 Data bit 2
- 1 Left audio 1 Data bit 1
- 0 Right audio 1 Data bit 0
-